﻿
$(document).ready(function () {
    getWareHourse(); //添加仓库
    getSelectUserGrid("SellerName"); //添加销售人员
    getSelectUserGrid("SenderName");  //添加送货人
    getClients();//添加客户

});
//添加仓库列表 ---开始
function getWareHourse() {
    $("#StorehouseName").ligerPopupEdit({
        grid: getGridOptions(false),
        valueField: 'Id',
        textField: 'StorehouseName'
    });
}
function getGridOptions(checkbox) {
    var options = {
        columns: [
                        { display: 'Key', name: 'Id', type: 'text', hide: 1 },
                        { display: '仓库名', name: 'StorehouseName', mintWidth: 80, width: 120 },
                        { display: '仓库编码', name: 'StorehouseCode', mintWidth: 80, width: 120 },
                        { display: '状态', name: 'DeletedSate', mintWidth: 60, width: 80 },
                        { display: '仓库类别', name: 'StorehouseTypeName', mintWidth: 80, width: 140 },
                        { display: '组织机构名称', name: 'OrgName', mintWidth: 80, width: 140 },
                         { display: '备注', name: 'Remarks', mintWidth: 140, width: 200 }
                    ], switchPageSizeApplyComboBox: false,
        url: "../WareHose/GetWareHoses?orgCode=" + $("#HidOrgCode").val() + "&rand=" + Math.random(),
        pageSize: 10,
        checkbox: checkbox
    };
    return options;
}

//添加仓库列表 ---结束

//添加用户列表 --开始
function getSelectUserGrid(controllerId) {
  //  $("#EmployeeName").ligerPopupEdit({
    $("#" + controllerId).ligerPopupEdit({
        grid: getUserGridOptions(false),
        valueField: 'Key',
        textField: 'Name'
    });
}
function getUserGridOptions(checkbox) {
    var options = {
        columns: [
                        { display: 'Key', name: 'Key', type: 'text', hide: 1 },
                        { display: '登陆名', name: 'LoginName', mintWidth: 80, width: 120 }, //, type: 'int', mintWidth: 40, width: 100
                        {display: '姓名', name: 'Name', mintWidth: 80, width: 120 },
                        { display: '性别', name: 'Gender', mintWidth: 60, width: 80 },
                        { display: '出生年月', name: 'Birthday', type: 'date', mintWidth: 100, width: 140 },
                        { display: '移动电话', name: 'Mobile', mintWidth: 80, width: 140 },
                        { display: '固定电话', name: 'Tel', mintWidth: 80, width: 140 },
                        { display: 'QQ', name: 'QQ', mintWidth: 80, width: 120 },
                        { display: '组织机构', name: 'OrgName', mintWidth: 80, width: 120 },
                        { display: '部门', name: 'DeptName', mintWidth: 80, width: 120 },
                        { display: '状态', name: 'IsEnable', mintWidth: 80, width: 120 }
                    ], switchPageSizeApplyComboBox: false,
        url: "../User/GetAllUsers?id=" + Math.random(),
        pageSize: 10,
        checkbox: checkbox
    };
    return options;
}
//添加用户列表 --结事

//添加客户列表 ---开始
function getClients() {
    $("#ClientName").ligerPopupEdit({
//        condition: {
//            prefixID: 'condtion_',
//            fields: [{ name: 'txt_ClientName',op : 'like', type: 'text', label: '客户名称' },
//                { name: 'txt_ClientCode', op: 'like', type: 'text', label: '客户编码' }
//            ]
        //        },
        // condition: { fields: [{ name: 'ClientName', op: 'like', vt: 'string', type: 'text', label: '客户名称'}] },
        grid: getClientGridOptions(false),
        valueField: 'Key',
        textField: 'ClientName'
    });
}
function getClientGridOptions(checkbox, paras) {
    var options = {
        columns: [
                            { display: 'Key', name: 'Key', type: 'text', hide: 1 },
                            { display: '客户名称', name: 'ClientName', mintWidth: 80, width: 120 }, //, type: 'int', mintWidth: 40, width: 100
                            {display: '客户编码', name: 'ClientCode', mintWidth: 100, width: 140 },
                            { display: '客户简称', name: 'ShortName', mintWidth: 100, width: 140 },
                            { display: '电话', name: 'ClientPhone', mintWidth: 80, width: 120 },
                            { display: '电子邮件', name: 'Email', mintWidth: 80, width: 120 },
                            { display: '开户行', name: 'BankName', mintWidth: 150, width: 200 },
                            { display: '银行账号', name: 'AccountNnmber', mintWidth: 100, width: 120 },
                            { display: '客户地址', name: 'ClientAddress', mintWidth: 100, width: 200 }
                    ], switchPageSizeApplyComboBox: false,
       url: "../Client/GetClients?rand=" + Math.random(),
       pageSize: 10,
       parms: paras,
        checkbox: checkbox
    };
    return options;
}

//添加客户列表 ---结束

